﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Product_UnitChange
    {
        //[Description("ID")]
            public long ID { get; set; }
       // [Description("ProductID")]
        public long ProductID { get; set; }
        //[Description("UnitID")]
            public long UnitID{get;set;}
        //[Description("UnitChangeID")]
            public long UnitChangeID{get;set;}
        [Description("Tỷ lệ")]
            public int Ratio{get;set;}
        [Description("Sử dụng")]
        public bool Active{get;set;}
        [Description("Đơn vị")]
        public string UnitExt { get; set; }
        [Description("Đơn vị đổi")]
        public string UnitChangeExt { get; set; }
        public string NameExt { get; set; }
        public Product_UnitChange()
        {       
        }
        
       static Product_UnitChange DynamicCast<T>(object row_data, object row_header) where T : Product_UnitChange
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Product_UnitChange ret = new Product_UnitChange();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                   case "ID":
                       ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "ProductID":
                       ret.ProductID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "UnitID":
                        ret.UnitID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "UnitChangeID":
                        ret.UnitChangeID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "Ratio":
                        ret.Ratio = ConvertObject.ToInt(dt[column]);
                       break;
                      case  "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                       break;
                   case "Unit":
                       ret.UnitExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "Unitchange":
                       ret.UnitChangeExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "Name":
                       ret.NameExt = ConvertObject.ToString(dt[column]);
                       break;
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
